<template>
<div>
  <p>用户名<input type="text" v-model="form.name"></p>
  <p>密码<input type="text" v-model="form.password"></p>
  <p>手机号<input type="text" v-model="form.sjh"></p>
  <p>验证码<input type="text" v-model="yzm">
    <button @click.prevent="get" :disabled="flag">{{ mes }}</button>
  </p>
  <button @click="add">注册</button>

</div>
</template>

<script>
export default {
  name: "zhuce",
  data(){
    return{
      form:{},
      flag:false,
      time : 60,
      mes:"获取短信验证码",
      yzm:""
    }
  },
  methods:{
    get() {
      this.$axios.post('users/SedSms/', {'sjh': this.form.sjh})
        .then(i => {
          let m = setInterval(() => {
            this.time--
            this.flag = true
            this.mes = this.time + "秒后操作"
            if (this.time == 0) {
              clearInterval(m)
              this.time = 60
              this.flag = false
              this.mes = "获取短信验证码"
            }
          }, 1000)
        })
    },
    add(){
      this.$axios.post('users/SedSms/', {'sjh': this.form.sjh})

    }
  },
  mounted() {
  }
}
</script>

<style scoped>

</style>
